define(function(require, exports, module) {
    "use strict";
    var $ = require("$"),
        app = require("dist/application/app"),
        config = app.config,
        method = app.method;
    var location_data = require("./data");
    var search = new method.select({
        data: location_data
    });
    var addresss = $('[data-toggle="address"]');
    $.each(addresss, function() {
        var $this = $(this),
            data = $this.data("location")
        var t = search.find(data);
        $this.prepend(t.toString)
    });
    $('[data-toggle="ajaxModal"]').bind('init', function(e, modal) {

        var $provinces = $('[data-location="provinces"]', modal)
        var $city = $('[data-location="city"]', modal)
        var $district = $('[data-location="district"]', modal)
        var sel = new method.select({
            data: location_data
        });
        sel.bind($provinces);
        sel.bind($city);
        sel.bind($district);

    });
 
    // var data = {}; //生成 区域
    // for (var Provinceid in location_data[0]) {
    //     var item = data["" + Provinceid + ""] = {};
    //     item.id = Provinceid;
    //     item.name = location_data[0][Provinceid];
    //     item.cities = {};
    //     var d = location_data["0,{0}".format(Provinceid)];
    //     for (var c in d) {
    //         item.cities["" + c + ""] = {};
    //         item.cities["" + c + ""].id = c;
    //         item.cities["" + c + ""].name = d[c];
    //     }
    //     // data.push(item);
    // };
    // console.log(window.JSON.stringify(data))
    // $("form").append("<textarea id=code cols=80 rows=15>{0}</textarea>".format(window.JSON.stringify(data)))

    return {
        select: method.select,
        data: location_data
    };
})
